#include <cstdint>
#include <iostream>
#include <istream>
#include <map>
#include <random>
#include <string>
#include <unordered_set>
#include <vector>

using ll = int64_t;
#define sl static inline

const int cnsize=3;
ll ltmp;
std::map<std::string, std::vector<std::string>> m;
std::vector<std::string> startw;
std::random_device rd;
std::mt19937 mt(rd());
std::unordered_set<std::string> old;

sl std::vector<std::string> stovs(const std::string &s){
    std::vector<std::string> ret;
    for(int i=0;i<s.size();i+=3){
        std::string ns;
        for(int j=0;j<cnsize&&i+j<s.size();j++){
            ns=ns+s[i+j];
        }
        ret.emplace_back(ns);
    }
    return ret;
}

int main(){
    while(std::cin>>ltmp){
        std::string b;
        std::cin>>b;
        std::vector<std::string> strs=stovs(b);
        // for(auto &i:strs){
        //     std::cout<<i<<"\n";
        // }
        old.emplace(b);
        startw.push_back(strs[0]);
        for(int i=1;i<strs.size();i++){
            m[strs[i-1]].push_back(strs[i]);
        }
    }

    std::uniform_int_distribution<int> uv(0,startw.size()-1);
    for(int i=1;i<=20;i++){
        // std::cout<<"i="<<i<<"\n";
        std::string now=startw[uv(mt)];
        std::string all;
        for(int j=1;j<=4;j++){
            all+=now;
            // std::cout<<now;
            if(m[now].size()==0)break;
            std::uniform_int_distribution<int> uvm(0,m[now].size()-1);
            now=m[now][uvm(mt)];
        }
        std::cout<<all;
        if(old.count(all)){
            std::cout<<" "<<"[is old]";
        }
        std::cout<<"\n";
    }
}